package aad.storyboard.controller;

import java.util.HashMap;

import aad.storyboard.R;
import aad.storyboard.model.BlackFader;
import aad.storyboard.model.BlueFader;
import aad.storyboard.model.Fader;
import aad.storyboard.model.GreenFader;
import aad.storyboard.model.RedFader;
import aad.storyboard.model.YellowFader;
import aad.storyboard.model.menu.MenuItem;
import aad.storyboard.view.BackButton;
import aad.storyboard.view.NextButton;
import aad.storyboard.view.PauseButton;
import android.app.Activity;
import android.graphics.Color;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

/**
 * Maintains a map of commands for all buttons in the navigation panel depending on which of the buttons has been clicked by the user, the corresponding NavigateCommand (back, pause or next will be triggered)
 */
public class NavigationClickListener implements OnClickListener {
	
	 private static HashMap<Integer, NavigateCommand> navigateStrategies=new HashMap<Integer, NavigateCommand>();
	 private NavigateCommand navigator;	 
	 private static NavigationClickListener inst=new NavigationClickListener ();
	 
	 public static NavigationClickListener getInstance(){    
	     
		 return inst;		 
	 }

	 /**
	  * register all buttons and the corresponding commands
	  * @param id
	  * @param command
	  */
	 public void register(int id, NavigateCommand command)
	 {
		 System.out.println("Registering id"+id+"Command "+command.toString());
		 navigateStrategies.put(id, command);
	 }
	 
	@Override
	public void onClick(View v) {
		int id = v.getId();
		int number = -1;		
		if(v.getTag() != null)
			number = ((Integer) v.getTag()).intValue();
		Log.e("Tag","clicked"+number);		
		this.navigator=navigateStrategies.get(id);		
		navigator.navigate();
	}
		
	}